<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/**
 *
 * @version 1.0
 * @author xpl0it
 */
class Login extends CI_Controller {

	 function __construct() {
	 	parent::__construct();
	 	$this->load->model('authmodel','authen');
	 }

	
	public function index(){
		if($this->session->userdata('data') == null && 
		  	$this->session->userdata('gen_hash') == null){
			$this->load->view('admin/login');
		}
	}
	public function auth(){
		$admin_authen = $this->authen;
		$user = $this->input->post('username');
		$pass = md5($this->input->post('password'));
		
		if($user != null && $pass != null){
			$val = $admin_authen->select_admin_user($user,$pass);
			if($val){
				redirect('admin/customer','refresh');
			}else{
				$this->load->view('admin/login');
			}
		}else{
			$this->load->view('admin/login');
		}

	}

	public function dashboard(){
			$this->checkauth();
			$data="";
			$content = $this->load->view('admin/index', $data,true);
			$content_data = new stdClass(); 
			$content_data->content = $content;
			$this->load->view('template/render',$content_data);

	}

	private function checkauth(){
		if(!$this->session->userdata('authen')){
			redirect('admin/login/','refresh');
		}
	}
	public function logout(){
		$this->session->sess_destroy();
		redirect('admin/login/','refresh');
	}

}

/* End of file welcome.php */
/* Location: ./application/controllers/admin/login.php */